package cn.gson.fengboot.controller;

import cn.gson.fengboot.aspect.MyLog;
import cn.gson.fengboot.model.pojos.Dneed;
import cn.gson.fengboot.model.pojos.Dntemplate;
import cn.gson.fengboot.model.service.DneedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/business/need")
public class DneedController {

    @Autowired
    DneedService service;

    @Autowired
    DbusinessController controller;


    /*查询需求模板*/
    @RequestMapping("/selectAllnt")
    public List<Dntemplate> selectAllnt(){
        return service.selectAllnt();
    }

    /*查询该商机的所有需求*/
    @RequestMapping("/selectAllnned")
    public List<Dneed> selectAllnned(Integer busId){
        return service.selectAllnned(busId);
    }

    /*新增商机需求*/
    @RequestMapping("/addneed")
    @MyLog(modul = "售前模块",desc = "新增商机客户需求")
    public void addneed(@RequestBody Dneed dneed){
        service.addneed(dneed);
    }

    /*新增数据需求模板*/
    @RequestMapping("/addntem")
    @MyLog(modul = "售前模块",desc = "新增商机客户需求模板")
    public void addntem(@RequestBody Dntemplate dntemplate){
        System.out.println(dntemplate.toString());
        service.addntem(dntemplate);
    }

    /*删除客户需求模板*/
    @RequestMapping("/detntem")
    @MyLog(modul = "售前模块",desc = "删除商机客户需求模板")
    public void detntem(Integer ntemplateId){
        service.detntem(ntemplateId);
    }

    @RequestMapping("/selectById")
    public Dneed selectById(Integer needId){
        return service.selectById(needId);
    }


    @RequestMapping("/selectByneedtheme")
    public Integer selectByneedtheme(String needTheme,HttpServletRequest request){
        String getbuspeople = controller.getbuspeople(request);
        return service.selectByneedtheme(needTheme,getbuspeople);
    }

}
